package respond

const (
	// Success codes
	SuccessOK      = 200
	SuccessCreated = 201

	// Client error codes
	ClientErrorBadRequest   = 400
	ClientErrorUnauthorized = 401
	ClientErrorForbidden    = 403
	ClientErrorNotFound     = 404

	// Server error codes
	ServerErrorInternal       = 500
	ServerErrorNotImplemented = 501

	// Custom application-specific codes
	CustomUserNotFound       = 1001
	CustomInvalidCredentials = 1002
	CustomAccountLocked      = 1003
)

var (
	CodeMap = map[string]int{
		"success":             SuccessOK,
		"created":             SuccessCreated,
		"error":               ServerErrorInternal,
		"not_found":           ClientErrorNotFound,
		"unauthorized":        ClientErrorUnauthorized,
		"forbidden":           ClientErrorForbidden,
		"bad_request":         ClientErrorBadRequest,
		"not_implemented":     ServerErrorNotImplemented,
		"internal":            ServerErrorInternal,
		"locked":              CustomAccountLocked,
		"invalid_credentials": CustomInvalidCredentials,
		"user_not_found":      CustomUserNotFound,
	}
)

func GetCode(key string) int {
	code, ok := CodeMap[key]
	if !ok {
		return ServerErrorInternal
	}
	return code
}
